<?php

class W3a_model extends CI_Model{

        //初始化
	function __construct(){
		parent::__construct();
		$this->load->database();
	}

	//获取网站管理信息
	function get_manager(){
		$list = $this->db->query('select * from w3a_manager');
		return $list->result();
	}

	//获取分类列表
	function get_category_list(){
		$list = $this->db->query('select * from w3a_type');
		return $list->result();
	}
	//文章页——文章list
	function get_article_list($parent_id){
		$list = $this->db->query('select * from w3a_news where news_parent_id ='.$parent_id);
		return $list->result();
	}
	//首页前台文章
	function index_article(){
		$list=$this->db->query('select * from w3a_news order by news_id desc limit 0,8');
		return $list->result();
	}
	//获取文章内容
	function get_article_content($art_id){
		$a_c = $this->db->query('select * from w3a_news where news_id = '.$art_id);
		return $a_c->result();
	}
	
	function get_item(){
		$res = $this->db->query('select * from w3a_news order by news_id desc limit 0,1');
		return $res->result();
	}	

	function get_new(){
		$res = $this->db->query('select * from w3a_news order by news_id desc limit 0,5');
		return $res->result();
	}
	//查询文章总数
	function get_all(){
		$query=$this->db->get('w3a_news');
		return $query->num_rows();
	}
	//分页
	function get_list($cid,$start = 0,$stop = 20){
		$sql = "select * from w3a_news where is_del = 0";
                if(!empty($cid)){
                    $sql .= " and type_id = ".$cid;
                }
                $sql .= " order by news_id desc limit ".$start.",".$stop;
		$res = $this->db->query($sql)->result_array();
		return $res;
	}
}

?>